package com.smzd.core.utils.db;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Page：普通的分页器，没有特别之处
 * 
 * @author yuzhongda
 * 
 * @param <E>
 *            elems类型参数
 */
public abstract class Page<E> {
	private List<E> elems;
	private Integer p;
	private int pageNo = 1;
	private int pageSize = 15;
	private int totalCount;

	/**
	 * 内部分页参数，不对外使用
	 */
	private int offset;
	/**
	 * 内部分页参数，不对外使用
	 */
	private int pageCount;

	/**
	 * 动态参数，使用时别忘了加上前缀，即#{params.xx}
	 */
	private Map<String, Object> params;

	// 常用固定参数
	private Integer id;
	private String sortName = "id";
	private String sortOrder = "asc";
	private String query;
	private String queryType;
	private String ext;
	private E elem;
	private Integer pq1;
	private Integer pq2;
	private Integer pq3;
	private Integer pq4;
	private Integer pq5;
	private Integer pq6;
	private Integer pq7;
	private Integer pq8;
	private String ps1;
	private String ps2;
	private String ps3;
	private String ps4;
	private String ps5;
	private String ps6;
	private String ps7;
	private String ps8;

	public List<E> getElems() {
		return elems;
	}

	public void setElems(List<E> elems) {
		this.elems = elems;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public Map<String, Object> getParams() {
		return params;
	}

	public void setParams(Map<String, Object> params) {
		this.params = params;
	}

	public void putParam(String key, Object value) {
		if (params == null) {
			params = new HashMap<String, Object>();
		}
		params.put(key, value);
	}

	public int getOffset() {
		return offset;
	}

	public void setOffset(int offset) {
		this.offset = offset;
	}

	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public Integer getId() {
		return id;
	}

	public String getSortName() {
		return sortName;
	}

	public String getSortOrder() {
		return sortOrder;
	}

	public String getQuery() {
		return query;
	}

	public String getQueryType() {
		return queryType;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public void setSortName(String sortName) {
		this.sortName = sortName;
	}

	public void setSortOrder(String sortOrder) {
		this.sortOrder = sortOrder;
	}

	public void setQuery(String query) {
		this.query = query;
	}

	public void setQueryType(String queryType) {
		this.queryType = queryType;
	}

	public String getExt() {
		return ext;
	}

	public E getElem() {
		return elem;
	}

	public void setExt(String ext) {
		this.ext = ext;
	}

	public void setElem(E elem) {
		this.elem = elem;
	}

	public Integer getP() {
		return p;
	}

	public void setP(Integer p) {
		this.p = p;
		if(p!=null){
			this.pageNo = p;
		}
	}

	public Integer getPq1() {
		return pq1;
	}

	public void setPq1(Integer pq1) {
		this.pq1 = pq1;
	}

	public Integer getPq2() {
		return pq2;
	}

	public void setPq2(Integer pq2) {
		this.pq2 = pq2;
	}

	public Integer getPq3() {
		return pq3;
	}

	public void setPq3(Integer pq3) {
		this.pq3 = pq3;
	}

	public Integer getPq4() {
		return pq4;
	}

	public void setPq4(Integer pq4) {
		this.pq4 = pq4;
	}

	public Integer getPq5() {
		return pq5;
	}

	public void setPq5(Integer pq5) {
		this.pq5 = pq5;
	}

	public Integer getPq6() {
		return pq6;
	}

	public void setPq6(Integer pq6) {
		this.pq6 = pq6;
	}

	public Integer getPq7() {
		return pq7;
	}

	public void setPq7(Integer pq7) {
		this.pq7 = pq7;
	}

	public Integer getPq8() {
		return pq8;
	}

	public void setPq8(Integer pq8) {
		this.pq8 = pq8;
	}

	public String getPs1() {
		return ps1;
	}

	public void setPs1(String ps1) {
		this.ps1 = ps1;
	}

	public String getPs2() {
		return ps2;
	}

	public void setPs2(String ps2) {
		this.ps2 = ps2;
	}

	public String getPs3() {
		return ps3;
	}

	public void setPs3(String ps3) {
		this.ps3 = ps3;
	}

	public String getPs4() {
		return ps4;
	}

	public void setPs4(String ps4) {
		this.ps4 = ps4;
	}

	public String getPs5() {
		return ps5;
	}

	public void setPs5(String ps5) {
		this.ps5 = ps5;
	}

	public String getPs6() {
		return ps6;
	}

	public void setPs6(String ps6) {
		this.ps6 = ps6;
	}

	public String getPs7() {
		return ps7;
	}

	public void setPs7(String ps7) {
		this.ps7 = ps7;
	}

	public String getPs8() {
		return ps8;
	}

	public void setPs8(String ps8) {
		this.ps8 = ps8;
	}

}
